﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Chat_D_LuX
{
    public partial class frmLogin : Form
    {

        //private ChatServiceRef.User user;

        public frmLogin()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            //ChatServiceRef.Chat_ServiceClient sr = new ChatServiceRef.Chat_ServiceClient();
            
            //try
            //{
            //    string un = txtUserName.Text.ToString();
            //    string pw = txtPassword.Text.ToString();

            //    user = sr.Login(un, pw);

            //    if (user != null)
            //    {
            //        frmMain = new frmMain();
            //    }
            //}

            
            //Service References being updated

            //// variable to hold value for user input
            //string user = txtUserName.Text;
            //string pass = txtPassword.Text;
            //bool logIn = false;

            ////creating service refrence to pass values to service for authentication
            //ClientRefrence.IService1 CLogIn = new ClientRefrence.Service1Client();
            //logIn = CLogIn.LogIn(user, pass, logIn);
            //if (logIn == true)
            //{
            //    this.Close();
            //}
            ////Prompt for registration if login failed
            //if (logIn == false)
            //{
            //    this.Hide();

            //    const string message =
            //    " The User Credentials you are trying to log in with are not valid. Would you like to create an account ? ";
            //    const string caption = "Log In Denied! ";
            //    var result = MessageBox.Show(message, caption,
            //                                         MessageBoxButtons.YesNo);
            //    if (result == System.Windows.Forms.DialogResult.Yes)
            //    {
            //        frmRegister RegUser = new frmRegister();
            //        RegUser.ShowDialog();
            //        this.Close();
            //    }
            //    else if (result == System.Windows.Forms.DialogResult.No)
            //    {
            //        Application.Exit();
            //    }
            //}
        }

        private void btnLogClear_Click(object sender, EventArgs e)
        {
            txtUserName.Text = "";
            txtPassword.Text = "";
            txtUserName.Focus();
        }

        private void lnkLblRegister_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {               
            //this.Dispose();// dispose of login form
            frmRegister frm = new frmRegister();            
            frm.ShowDialog();
            //TODO if register fails or new user not created needs to exit application
            //likely handled in service layer
        }
    }
}
